package com.example.CarManagement.sys.controller;

import com.example.CarManagement.common.Result;
import com.example.CarManagement.sys.entity.ApprovalFlows;
import com.example.CarManagement.sys.service.impl.ApprovalFlowsServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;

/**
 * <p>
 * 审批流程定义表，定义不同类型的用车申请的审批流程 前端控制器
 * </p>
 *
 * @author 徐佳彪
 * @since 2025-07-17
 */
@RestController
@RequestMapping("/sys/approvalFlows")
public class ApprovalFlowsController {

    @Autowired
    private ApprovalFlowsServiceImpl approvalFlowsService;

    // 添加
    @PreAuthorize("@se.hasPermi('APPROVALFLOWS_INSERT')")
    @PostMapping("/add")
    public Result<?> add(@RequestBody ApprovalFlows approvalFlows) {

        return approvalFlowsService.add(approvalFlows);
    }

    // 删除
    @PreAuthorize("@se.hasPermi('APPROVALFLOWS_DELETE')")
    @DeleteMapping("/delete/{id}")
    public Result<?> delete(@PathVariable String id) {
        return Result.success(approvalFlowsService.deleteFlows(id));
    }

    // 修改
    @PreAuthorize("@se.hasPermi('APPROVALFLOWS_UPDATE')")
    @PutMapping("/update")
    public Result<?> update(@RequestBody ApprovalFlows approvalFlows) {
        return Result.success(approvalFlowsService.updateById(approvalFlows));
    }

    // 查询
    @PreAuthorize("@se.hasPermi('APPROVALFLOWS_SELECT')")
    @GetMapping("/list")
    public Result<?> list() {
        return Result.success(approvalFlowsService.list());
    }

}
